<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:  Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Mar 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/employer/tmpl/formjob.php
 ^ 
 * Description: template for form job
 ^ 
 * History:		NONE
 ^ 
 */
 

defined('_JEXEC') or die('Restricted access');

 global $mainframe;

jimport('joomla.html.pane');

$editor = & JFactory :: getEditor();
JHTML :: _('behavior.calendar');

    $document = &JFactory::getDocument();
    $document->addStyleSheet('components/com_wrecruit/css/'.$this->config['theme']);
	$version = new JVersion;
	$joomla = $version->getShortVersion();
	$jversion = substr($joomla,0,3);

	$dateformat = $this->config['date_format'];
	$firstdash = strpos($dateformat,'-',0);
	$firstvalue = substr($dateformat, 0,$firstdash);
	$firstdash = $firstdash + 1;
	$seconddash = strpos($dateformat,'-',$firstdash);
	$secondvalue = substr($dateformat, $firstdash,$seconddash-$firstdash);
	$seconddash = $seconddash + 1;
	$thirdvalue = substr($dateformat, $seconddash,strlen($dateformat)-$seconddash);
	$js_dateformat = '%'.$firstvalue.'-%'.$secondvalue.'-%'.$thirdvalue;
  
?>

<?php if ($this->config['offline'] == '1'){ ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" >
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	<?php echo $this->config['title']; ?></td></tr>
	<tr><td height="25"></td></tr>
	<tr><td class="wrecruitmsg">
		<?php echo $this->config['offline_text']; ?>
	</td></tr>
</table>	
<?php }else{ ?>

<script language="javascript">
	function hideShowRange(hideSrc, showSrc, showName, showVal){
		document.getElementById(hideSrc).style.visibility = "hidden";
		document.getElementById(showSrc).style.visibility = "visible";
		document.getElementById(showName).value = showVal;
	
	}
 
	function myValidate(f) {
		var returnvalue = true;
		
/*		if (f.id.value == ''){
			if (CheckDate()== false) returnvalue = false; 
		}
*/		if (document.formvalidator.isValid(f)) {
                f.check.value='<?php echo JUtility::getToken(); ?>';//send token
        } else {
                alert('<?php echo JText::_( 'JS_SOME_VALUES_ARE_NOT_ACCEPTABLE_PLEASE_RETRY');?>');
				returnvalue = false;
        }
		if (returnvalue == true)
			return true;
		else{	
			return false;
		}	
}

function CheckDate() {
//alert('date');
	f = document.adminForm;
	var returnvalue = true;
	var today=new Date()
	if ((today.getMonth()+1) < 10)
		var tomonth = "0"+(today.getMonth()+1);
	else
		var tomonth = (today.getMonth()+1);
	
	if ((today.getDate()) < 10)
		var day = "0"+(today.getDate());
	else
		var day = (today.getDate());

		var todate = (today.getYear()+1900)+"-"+tomonth+"-"+day;
	
//alert(todate);
		if(f.startpublishing.value != ""){
			if (todate > f.startpublishing.value ){
				alert('Please enter a valid start publishing date');
				f.startpublishing.value="";
				returnvalue = false;
			}
		}		
		if(f.startpublishing.value >= f.stoppublishing.value){
			alert("Please enter a valid stop publishing date");
			f.stoppublishing.value="";
			returnvalue = false;
		}
		return returnvalue;
	
}
</script>

<table cellpadding="0" cellspacing="0" border="0" width="100%" >
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	
		<?php echo $this->config['title']; ?>
	</td>
	</tr>
	<tr><td height="23"></td></tr>
	<?php if ($this->config['cur_location'] == 1) {?>
	<tr><td height="0"></td></tr>
	<tr><td class="curloc">
		<?php if (isset($this->job)&& ($this->job->id == '')){	?>
			<?php echo JText::_('JS_CUR_LOC'); ?> :  <?php echo JText::_('JS_NEW_JOB_INFO'); ?>
		<?php }else{	?>
			<?php echo JText::_('JS_CUR_LOC'); ?> : <a href="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=myjobs&Itemid=<?php echo $this->Itemid; ?>" class="curloclnk"><?php echo JText::_('JS_MY_JOBS'); ?></a> > <?php echo JText::_('JS_EDIT_JOB_INFO'); ?>
		<?php }	?>
	</td></tr>
	<?php } ?>
	<tr><td>
		<?php 
			if (sizeof($this->employerlinks) != 0){
				echo '<div id="toplinks"><ul>';
				foreach($this->employerlinks as $lnk)	{ ?>
					<span <?php if($lnk[2] == 1)echo 'class="first"'; elseif($lnk[2] == -1)echo 'class="last"';  ?>>
						<a href="<?php echo $lnk[0]; ?>"> <?php echo $lnk[1]; ?></a>
					</span>
				<?php }
				echo '<ul></div>';			
			}
		?>
	</td></tr>	
	<tr><td height="3"></td></tr>
	<tr><td class="<?php echo $this->theme['heading']; ?>" align="center">
		<?php echo JText::_('JS_JOB_INFO'); ?>
	</td></tr>
	<tr><td height="10"></td></tr>
</table>
<?php
if ($this->userrole->rolefor == 1) { // employer
if ($this->canaddnewjob == 1) { // add new job, in edit case always 1
?>
<form action="index.php" method="post" name="adminForm" id="adminForm" class="form-validate"  onSubmit="return myValidate(this);">
    <table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminform">
		<?php
		$i = 0;
		foreach($this->fieldsordering as $field){ 
			//echo '<br> uf'.$field->field;
			switch ($field->field) {
				
				case "jobtitle": ?>
				  <tr>
			        <td width="17%" align="right"><label id="titlemsg" for="title"><?php echo JText::_('JS_JOB_TITLE'); ?></label>&nbsp;<font color="red">*</font></td>
			          <td ><input class="inputbox required" type="text" name="title" id="title" size="40" maxlength="255" value="<?php if(isset($this->job)) echo $this->job->title; ?>" />
			        </td>
			      </tr>
				<?php break;
				case "company": ?>
				 
                                    <input type="hidden" name="companyid" value="<?php echo $this->wr_company->id; ?>"></input>
                                    <?php //echo $this->lists['companies']; ?>
			      
				<?php break;
				case "department": ?>
				  <tr>
			        <td valign="top" align="right"><label id="departmentmsg" for="department"><?php echo JText::_('JS_DEPARTMENT'); ?></label></td>
				    <td  id="department"><?php  if(isset($this->lists['departments'])) echo $this->lists['departments']; ?></td> 
			      </tr>
				<?php break;
				case "jobcategory": ?>
			      <tr>
			        <td valign="top" align="right"><?php echo JText::_('JS_CATEGORIES'); ?></td>
			        <td ><?php echo $this->lists['jobcategory']; ?></td>
			      </tr>
				<?php break;
				case "subcategory":   ?>
			      <tr >
			        <td valign="top" align="right"><?php echo JText::_('JS_SUB_CATEGORY'); ?></td>
			        <td id="fj_subcategory"><?php echo $this->lists['subcategory']; ?></td>
			      </tr>
				<?php break;
				case "jobtype": ?>
			      <?php if ( $field->published == 1 ) { ?>
				  <tr>
			        <td valign="top" align="right"><?php echo JText::_('JS_JOBTYPE'); ?></td>
			        <td ><?php echo $this->lists['jobtype']; ?></td>
			      </tr>
				  <?php } ?>
				<?php break;
				case "jobstatus": ?>
			      <tr>
			        <td valign="top" align="right"><?php echo JText::_('JS_JOBSTATUS'); ?></td>
			        <td ><?php echo $this->lists['jobstatus']; ?></td>
			      </tr>
				<?php break;
				case "jobshift": ?>
			      <?php if ( $field->published == 1 ) { ?>
			      <tr>
			        <td valign="top" align="right"><?php echo JText::_('JS_SHIFT'); ?></td>
			        <td ><?php echo $this->lists['shift']; ?></td>
			      </tr>
				  <?php } ?>
				<?php break;
				case "jobsalaryrange": ?>
			      <?php if ( $field->published == 1 ) { ?>
			      <tr>
			        <td valign="top" align="right"><?php echo JText::_('JS_SALARYRANGE'); ?></td>
			        <td >
					<?php echo $this->lists['currencyid']; ?>&nbsp;&nbsp;&nbsp;
					<?php echo $this->lists['salaryrangefrom']; ?>&nbsp;&nbsp;&nbsp;
					<?php echo $this->lists['salaryrangeto']; ?>&nbsp;&nbsp;&nbsp;
					<?php echo $this->lists['salaryrangetypes']; ?>&nbsp;&nbsp;&nbsp;
				</td>
			      </tr>
					<?php /*
					<tr>
					  <td valign="top" align="right"><?php echo JText::_('JS_HIDE_SALARY'); ?></td>
					  <td><input type='checkbox' name='hidesalaryrange' value='1' <?php if(isset($this->job)) echo ($this->job->hidesalaryrange == "1") ? "checked='checked'" : ""; ?> /></td>
					</tr>
					      */ ?>
				  <?php } ?>
				<?php break;
				case "heighesteducation": ?>
			      <?php if ( $field->published == 1 ) { ?>
					<tr>
					<td valign="top" align="right"><?php echo JText::_('JS_EDUCATION'); ?></td>
					<td height="31"   valign="top">
						<?php
							if(isset($this->job)) $iseducationminimax = $this->job->iseducationminimax; else $iseducationminimax = 1;
							if ($iseducationminimax == 1) {
								$educationminimaxdivstyle = "position:absolute;";
								$educationrangedivstyle = "visibility:hidden;position:absolute;";
							}else{
								$educationminimaxdivstyle = "visibility:hidden;position:absolute;";
								$educationrangedivstyle = "position:absolute;";
							}	
						?>
						<input type="hidden" name="iseducationminimax" id="iseducationminimax" value="<?php echo $iseducationminimax; ?>">
						<div id="educationminimaxdiv" style="<?php echo $educationminimaxdivstyle; ?>">
							<?php echo $this->lists['educationminimax']; ?>&nbsp;&nbsp;&nbsp;
							<?php echo $this->lists['education']; ?>&nbsp;&nbsp;&nbsp;
							<a  onclick="hideShowRange('educationminimaxdiv','educationrangediv','iseducationminimax',0);" style="cursor:pointer;"><?php echo JText::_('JS_SPECIFY_RANGE'); ?></a>
						</div>
						<div id="educationrangediv" style="<?php echo $educationrangedivstyle; ?>">
							<?php echo $this->lists['minimumeducationrange']; ?>&nbsp;&nbsp;&nbsp;
							<?php echo $this->lists['maximumeducationrange']; ?>&nbsp;&nbsp;&nbsp;
							<a onclick="hideShowRange('educationrangediv','educationminimaxdiv','iseducationminimax',1);" style="cursor:pointer;"><?php echo JText::_('JS_CANCEL_RANGE'); ?></a>
						</div>
					</td>
				      </tr>
					<tr>
					<td valign="top" align="right"><label id="degreetitlesmsg" for="degreetitle"><?php echo JText::_('JS_DEGREE_TITLE'); ?></label></td>
					<td ><input class="inputbox" type="text" name="degreetitle" id="degreetitle" size="30" maxlength="40" value="<?php if(isset($this->job)) echo $this->job->degreetitle; ?>" />
					</td>
					</tr>
					<?php } ?>
				<?php break;
				case "noofjobs": ?>
					<tr>
					<td valign="top" align="right"><label id="noofjobsmsg" for="noofjobs"><?php echo JText::_('JS_NOOFJOBS'); ?></label>&nbsp;<font color="red">*</font></td>
					<td ><input class="inputbox  required validate-numeric" type="text" name="noofjobs" id="noofjobs" size="10" maxlength="10" value="<?php if(isset($this->job)) echo $this->job->noofjobs; ?>" />
					</td>
					</tr>
				<?php break;
				case "experience": ?>
			      <?php if ( $field->published == 1 ) { ?>
			       <tr>
			        <td valign="top" align="right"><label id="experiencesmsg" for="experience"><?php echo JText::_('JS_EXPERIENCE'); ?></label></td>
			        <td height="31"   valign="top">
					<?php
						if(isset($this->job)) $isexperienceminimax = $this->job->isexperienceminimax; else $isexperienceminimax = 1;
						if ($isexperienceminimax == 1) {
							$experienceminimaxdivstyle = "position:absolute;";
							$experiencerangedivstyle = "visibility:hidden;position:absolute;";
						}else{
							$experienceminimaxdivstyle = "visibility:hidden;position:absolute;";
							$experiencerangedivstyle = "position:absolute;";
						}	
					?>
					<input type="hidden" name="isexperienceminimax" id="isexperienceminimax" value="<?php echo $isexperienceminimax; ?>">
					<div id="experienceminimaxdiv" style="<?php echo $experienceminimaxdivstyle; ?>">
						<?php echo $this->lists['experienceminimax']; ?>&nbsp;&nbsp;&nbsp;
						<?php echo $this->lists['experience']; ?>&nbsp;&nbsp;&nbsp;
						<a  onclick="hideShowRange('experienceminimaxdiv','experiencerangediv','isexperienceminimax',0);" style="cursor:pointer;"><?php echo JText::_('JS_SPECIFY_RANGE'); ?></a>
					</div>
					<div id="experiencerangediv" style="<?php echo $experiencerangedivstyle; ?>">
						<?php echo $this->lists['minimumexperiencerange']; ?>&nbsp;&nbsp;&nbsp;
						<?php echo $this->lists['maximumexperiencerange']; ?>&nbsp;&nbsp;&nbsp;
						<a onclick="hideShowRange('experiencerangediv','experienceminimaxdiv','isexperienceminimax',1);" style="cursor:pointer;"><?php echo JText::_('JS_CANCEL_RANGE'); ?></a>
					</div>
			        </td>
						
			      </tr>
			       <tr>
			        <td valign="top" align="right"></td>
			        <td height="31"   valign="top">
					<input class="inputbox" type="text" name="experiencetext" id="experiencetext" size="30" maxlength="150" value="<?php if(isset($this->job)) echo $this->job->experiencetext; ?>" />
					&nbsp;&nbsp;&nbsp;<?php echo JText::_('JS_ANY_OTHER_EXPERIENCE'); ?>
			        </td>
			      </tr>
				  <?php } ?>
				<?php break;
				case "duration": ?>
			      <?php if ( $field->published == 1 ) { ?>
			       <tr>
			        <td valign="top" align="right"><label id="durationmsg" for="duration"><?php echo JText::_('JS_DURATION'); ?></label></td>
			        <td ><input class="inputbox" type="text" name="duration" id="duration" size="10" maxlength="15" value="<?php if(isset($this->job)) echo $this->job->duration; ?>" />
			        <?php echo JText::_('JS_DURATION_DESC'); ?>
					</td>
			      </tr>
				  <?php } ?>
				<?php break;
				case "startpublishing": ?>
					<?php 
						$startdatevalue = '';
						if(isset($this->job)) $startdatevalue = date($this->config['date_format'],strtotime($this->job->startpublishing));
						?>
						<tr>
							<td valign="top" align="right"><label id="startpublishingmsg" for="startpublishing"><?php echo JText::_('JS_START_PUBLISHING'); ?></label>&nbsp;<font color="red">*</font></td>
							<td ><?php if(($this->packagedetail[2] == 1) && (isset($this->job))){ //edit
								if($jversion == '1.5') { ?> <input class="inputbox required" type="text" name="startpublishing" id="job_startpublishing" readonly class="Shadow Bold" size="10" value="<?php if(isset($this->job)) echo  date($this->config['date_format'],strtotime($this->job->startpublishing)); ?>" />
									<?php } else echo JHTML::_('calendar', $this->job->startpublishing,'startpublishing', 'job_startpublishing',$js_dateformat,array('class'=>'inputbox', 'size'=>'10',  'maxlength'=>'19','readonly'=>'readonly')); ?>
								<?php //}
							}else { 
								if($jversion == '1.5'){ ?><input class="inputbox required" type="text" name="startpublishing" id="job_startpublishing" readonly class="Shadow Bold" size="10" value="<?php if(isset($this->job)) echo  date($this->config['date_format'],strtotime($this->job->startpublishing)); ?>" />
								<input type="reset" class="button" value="..." onclick="return showCalendar('job_startpublishing','<?php echo $js_dateformat; ?>');"  />
								<?php 
								}else	echo JHTML::_('calendar', '','startpublishing', 'job_startpublishing',$js_dateformat,array('class'=>'inputbox required', 'size'=>'10',  'maxlength'=>'19')); ?>

						<?php } ?>
							</td>
					</tr>
				<?php break;
				case "stoppublishing": ?>
					<?php 
						$stopdatevalue = '';
						//if(isset($this->job)) $stopdatevalue = date($this->config['date_format'],strtotime($this->job->stoppublishing));
						?>
			       <tr>
			        <td valign="top" align="right"><label id="stoppublishingmsg" for="stoppublishing"><?php echo JText::_('JS_STOP_PUBLISHING'); ?></label>&nbsp;<font color="red">*</font></td>
			        <td ><?php if($this->packagedetail[2] == 1){
									if(isset($this->job)){ 
										if($jversion == '1.5') { ?> <input class="inputbox required" type="text" name="stoppublishing" id="job_stoppublishing" readonly class="Shadow Bold" size="10" value="<?php if(isset($this->job)) echo  date($this->config['date_format'],strtotime($this->job->stoppublishing)); ?>" />
										<?php } 
										else { echo JHTML::_('calendar', $this->job->stoppublishing,'stoppublishing', 'job_stoppublishing',$js_dateformat,array('class'=>'inputbox required', 'size'=>'10',  'maxlength'=>'19','readonly'=>'readonly')); ?>
										<?php } ?>
								  <?php }else{
										if($this->packagedetail[4] == 1) $enforcetype = JText::_('JS_DAYS');
										elseif($this->packagedetail[4] == 2) $enforcetype = JText::_('JS_WEEKS');
										elseif($this->packagedetail[4] == 3) $enforcetype = JText::_('JS_MONTHS');
										echo $this->packagedetail[3].' '.$enforcetype;
									    }
                                }else {
									if($jversion == '1.5'){ ?><input class="inputbox required" type="text" name="stoppublishing" id="job_stoppublishing" readonly class="Shadow Bold" size="10" value="<?php if(isset($this->job)) echo  date($this->config['date_format'],strtotime($this->job->stoppublishing)); ?>" />
										<input type="reset" class="button" value="..." onclick="return showCalendar('job_stoppublishing','<?php echo $js_dateformat; ?>');"  />

									<?php 
									}else echo JHTML::_('calendar', $this->job->stoppublishing,'stoppublishing', 'job_stoppublishing',$js_dateformat,array('class'=>'inputbox required', 'size'=>'10',  'maxlength'=>'19')); ?>

						<?php   } ?>
				</td>
			      </tr>
				<?php break;
				case "age": ?>
				<?php if ( $field->published == 1 ) { ?>
					<tr>
					 <td valign="top" align="right"><label id="agefrommsg" for="agefrom"><?php echo JText::_('JS_AGE'); ?></label><?php if($field->required == 1) echo '&nbsp;<font color="red">*</font>'; ?></td>
					 <td ><?php echo $this->lists['agefrom']; ?>&nbsp;&nbsp;&nbsp;
					 <?php echo $this->lists['ageto']; ?>
					 </td>
				       </tr>
				<?php } ?>
				<?php break;
				case "gender": ?>
				<?php if ( $field->published == 1 ) { ?>
					<tr>
					 <td valign="top" align="right"><label id="gendermsg" for="gender"><?php echo JText::_('JS_GENDER'); ?><?php if($field->required == 1) echo '&nbsp;<font color="red">*</font>'; ?></label></td>
					 <td ><?php echo $this->lists['gender']; ?></td>
				       </tr>
				<?php } ?>
				<?php break;
				case "careerlevel": ?>
				<?php if ( $field->published == 1 ) { ?>
					<tr>
					 <td valign="top" align="right"><label id="careerlevelmsg" for="careerlevel"><?php echo JText::_('JS_CAREER_LEVEL'); ?></label></td>
					 <td ><?php echo $this->lists['careerlevel']; ?></td>
				       </tr>
				<?php } ?>

				<?php break;
				case "workpermit": ?>
				<?php if ( $field->published == 1 ) { ?>
					<tr>
					 <td valign="top" align="right"><label id="workpermitmsg" for="workpermit"><?php echo JText::_('JS_WORK_PERMIT'); ?></label></td>
					 <td ><?php echo $this->lists['workpermit']; ?></td>
				       </tr>
				<?php } ?>
				<?php break;
				case "requiredtravel": ?>
				<?php if ( $field->published == 1 ) { ?>
					<tr>
					 <td valign="top" align="right"><label id="requiredtravelmsg" for="requiredtravel"><?php echo JText::_('JS_REQUIRED_TRAVEL'); ?></label></td>
					 <td ><?php echo $this->lists['requiredtravel']; ?></td>
				       </tr>
				<?php } ?>

				<?php break;
				case "description": ?>
					<?php if ( $this->config['job_editor'] == 1 ) { ?>
							<tr><td height="10" colspan="54"></td></tr>
							<tr>
								<td colspan="54" valign="top" align="center"><label id="descriptionmsg" for="description"><strong><?php echo JText::_('JS_DESCRIPTION'); ?></strong></label>&nbsp;<font color="red">*</font></td>
							</tr>
							<tr>
								<td colspan="54" align="center">
								<?php
									$editor =& JFactory::getEditor();
									if(isset($this->job))
										echo $editor->display('description', $this->job->description, '550', '300', '60', '20', false);
									else
										echo $editor->display('description', '', '550', '300', '60', '20', false);

								?>	
									<!--<textarea class="inputbox required" name="description" id="description" cols="60" rows="5"><?php if(isset($this->job)) echo $this->job->description; ?></textarea>-->
								</td>
							</tr>
					<?php }else{ ?>
							<tr>
								<td valign="top" align="right"><label id="descriptionmsg" for="description"><?php echo JText::_('JS_DESCRIPTION'); ?></label>&nbsp;<font color="red">*</font></td>
								<td ><textarea class="inputbox required" name="description" id="description" cols="60" rows="5"><?php if(isset($this->job)) echo $this->job->description; ?></textarea></td>
							</tr>
					<?php } ?>
				<?php break;
				case "agreement": ?>
					<?php if ( $this->config['job_editor'] == 1 ) { ?>
							<tr><td height="10" colspan="54"></td></tr>
							<tr>
								<td colspan="2" valign="top" align="center"><label id="agreementmsg" for="agreement"><strong><?php echo JText::_('JS_AGREEMENT'); ?></strong></td>
							</tr>
							<tr>
								<td colspan="54" align="center">
								<?php
									$editor =& JFactory::getEditor();
									if(isset($this->job))
										echo $editor->display('agreement', $this->job->agreement, '550', '300', '60', '20', false);
									else
										echo $editor->display('agreement', '', '550', '300', '60', '20', false);

								?>	
								</td>
							</tr>
					<?php }else{ ?>
							<tr>
								<td valign="top" align="right"><label id="agreementmsg" for="agreement"><?php echo JText::_('JS_DESCRIPTION'); ?></label>&nbsp;<font color="red">*</font></td>
								<td ><textarea class="inputbox required" name="agreement" id="agreement" cols="60" rows="5"><?php if(isset($this->job)) echo $this->job->agreement; ?></textarea></td>
							</tr>
					<?php } ?>
				<?php break;
				case "qualifications": ?>
						<?php if ( $field->published == 1 ) { ?>
							<tr><td height="10" colspan="54"></td></tr>
							<tr>
								<td colspan="54" valign="top" align="center"><label id="qualificationsmsg" for="qualifications"><strong><?php echo JText::_('JS_QUALIFICATIONS'); ?></strong></label></td>
							</tr>
							<tr>
								<td colspan="54" align="center">
								<?php
									$editor =& JFactory::getEditor();
									if(isset($this->job))
										echo $editor->display('qualifications', $this->job->qualifications, '550', '300', '60', '20', false);
									else
										echo $editor->display('qualifications', '', '550', '300', '60', '20', false);

								?>	
								</td>
							</tr>
					<?php }else{ ?>
					      <?php if ( $field->published == 1 ) { ?>
							<tr>
								<td valign="top" align="right"><?php echo JText::_('JS_QUALIFICATIONS');?></td>
								<td ><textarea class="inputbox" name="qualifications" id="qualifications" cols="60" rows="5"><?php if(isset($this->job)) echo $this->job->qualifications; ?></textarea></td>
							</tr>
							<?php } ?>
					<?php } ?>
				<?php break;
				case "prefferdskills": ?>
	 			    <?php if ( $this->config['job_editor'] == 1 ) { ?>
						<?php if ( $field->published == 1 ) { ?>
							<tr><td height="10" colspan="54"></td></tr>
							<tr>
								<td colspan="54" valign="top" align="center"><label id="prefferdskillsmsg" for="prefferdskills"><strong><?php echo JText::_('JS_PREFFERD_SKILLS'); ?></strong></label></td>
							</tr>
							<tr>
								<td colspan="54" align="center">
								<?php
									$editor =& JFactory::getEditor();
									if(isset($this->job))
										echo $editor->display('prefferdskills', $this->job->prefferdskills, '550', '300', '60', '20', false);
									else
										echo $editor->display('prefferdskills', '', '550', '300', '60', '20', false);
								?>	
								</td>
							</tr>
							<?php } ?>

					<?php }else{ ?>
						<?php if ( $field->published == 1 ) { ?>
							<tr>
								<td valign="top" align="right"><label id="prefferdskillsmsg" for="prefferdskills"><?php echo JText::_('JS_PREFFERD_SKILLS'); ?></label></td>
								<td >
									<textarea class="inputbox" name="prefferdskills" id="prefferdskills" cols="60" rows="5"><?php if(isset($this->job)) echo $this->job->prefferdskills; ?></textarea>
								</td>
							</tr>
							<?php } ?>
					<?php } ?>
					<?php break;
				case "country": ?>
				      <tr>
				        <td align="right"><label id="countrymsg" for="country"><?php echo JText::_('JS_COUNTRY'); ?></label></td>
				        <td  id="job_country">
						      <?php echo $this->lists['country']; ?>
				        </td>
				      </tr>
				<?php break;
				case "state": ?>
					  <?php if ( $field->published == 1 ) { ?>
				      <tr>
				        <td align="right"><label id="statemsg" for="state"><?php echo JText::_('JS_STATE'); ?></label></td>
				        <td  id="job_state">
						<?php
							if ((isset($this->lists['state'])) && ($this->lists['state']!='')){
								echo $this->lists['state']; 
							} else{ ?>
								<input class="inputbox" type="text" name="state" size="40" maxlength="100" value="<?php if(isset($this->job)) echo $this->job->state; ?>" />
							<?php } ?>
						</td>
				      </tr>
					  <?php } ?>
				<?php break;
				case "county": ?>
					  <?php if ( $field->published == 1 ) { ?>
				      <tr>
				        <td align="right"><label id="countymsg" for="county"><?php echo JText::_('JS_COUNTY'); ?></label></td>
				        <td  id="job_county">
						<?php 
							if ((isset($this->lists['county'])) && ($this->lists['county']!='')){
								echo $this->lists['county']; 
							} else{ ?>
								<input class="inputbox" type="text" name="county" size="40" maxlength="100" value="<?php if(isset($this->job)) echo $this->job->county; ?>" />
							<?php } ?>
				        </td>
				      </tr>
					  <?php } ?>
				<?php break;
				case "city": ?>
					  <?php if ( $field->published == 1 ) { ?>
				      <tr>
				        <td align="right"><label id="citymsg" for="city"><?php echo JText::_('JS_CITY'); ?></label></td>
				        <td  id="job_city">
						<?php 
							if((isset($this->lists['city'])) && ($this->lists['city']!='')){
								echo $this->lists['city']; 
							} else{ ?>
								<input class="inputbox" type="text" name="city" size="40" maxlength="100" value="<?php if(isset($this->job)) echo $this->job->city; ?>" />
							<?php } ?>
				        </td>
				      </tr>
					  <?php } ?>
			<?php break;
			case "metadescription": ?>
				  <tr>
			       <td align="right" ><label id="metadescriptionmsg" for="metadescription"><?php echo JText::_('JS_META_DESCRIPTION'); ?></label></td>
				 <td>
				<textarea cols="45" rows="5" class="inputbox " name="metadescription" id="metadescription" ><?php if(isset($this->job)) echo $this->job->metadescription; ?></textarea>
				</td>
			      </tr>
                        <?php break;
			case "metakeywords": ?>
				  <tr>
					<td  align="right" ><label id="metakeywordsmsg" for="metakeywords"><?php echo JText::_('JS_META_KEYWORDS'); ?></label></td>
					
					<td>
					  <textarea cols="45" rows="5" class="inputbox" name="metakeywords" id="metakeywords" ><?php if(isset($this->job)) echo $this->job->metakeywords; ?></textarea>
					</td>
			    </tr>
                        <?php break;
			case "video": ?>
				  <tr>
			        <td width="3%" align="right"><label id="videomsg" for="video"><?php echo JText::_('JS_VIDEO'); ?></label></td>
			          <td ><input class="inputbox" type="text" name="video" id="video" size="40" maxlength="255" value="<?php if(isset($this->job)) echo $this->job->video; ?>" />
                                      YouTube video id

			        </td>
			      </tr>
				<?php break;
				case "map": ?>
				  <tr>
			        <td width="3%" align="right"><label id="mapmsg" for="map"><?php echo JText::_('JS_MAP'); ?></label></td>
			          <td ><input class="inputbox " type="text" name="map" id="map" size="40" maxlength="500" value="<?php if(isset($this->job)) echo $this->job->map; ?>" />
                                      Google map source
			        </td>
			      </tr>
				<?php break;
				case "sendrecruited": 
				if(isset($this->job) && !$this->job->sendrecruited){
					?>
				  <tr>
			        <td width="3%" align="right"><label id="sendrecruitedmsg" for="sendrecruited"></label></td>
			          <td ><input class="inputbox " type="checkbox" name="sendrecruited" id="sendrecruited" value="1" />
                                      <?php echo JText::_('JS_SENDRECRUITE'); ?>
			        </td>
			      </tr>
				<?php
				} 
					break;
				case "sendemail": ?>
					<tr>
				        <td valign="top" align="right"><?php echo JText::_('JS_SEND_EMAIL'); ?></td>
				        <td ><?php echo $this->lists['sendemail']; ?></td>
				      </tr>
				<?php break;
				  
				default:
					//echo '<br> default uf '.$filed->field;
					if ( $field->published == 1 ) { 
					
						foreach($this->userfields as $ufield){ 
							if($field->field == $ufield[0]->id) {
								$userfield = $ufield[0];
								$i++;
								echo "<tr><td valign='top' align='right'>";
								if($userfield->required == 1){
									echo "<label id=".$userfield->name."msg for=$userfield->name>$userfield->title</label>&nbsp;<font color='red'>*</font>";
									if($userfield->type == 'emailaddress') $cssclass = "class ='inputbox required validate-email' ";
									else $cssclass = "class ='inputbox required' ";
								}else{
									echo $userfield->title;
									if($userfield->type == 'emailaddress') $cssclass = "class ='inputbox validate-email' ";
									else  $cssclass = "class='inputbox' ";
								}
								echo "</td><td>"	;
									
								$readonly = $userfield->readonly ? ' readonly="readonly"' : '';
		   						$maxlength = $userfield->maxlength ? 'maxlength="'.$userfield->maxlength.'"' : '';
								if(isset($ufield[1])){ $fvalue = $ufield[1]->data; $userdataid = $ufield[1]->id;}  else {$fvalue=""; $userdataid = ""; }
								echo '<input type="hidden" id="userfields_'.$i.'_id" name="userfields_'.$i.'_id"  value="'.$userfield->id.'"  />';
								echo '<input type="hidden" id="userdata_'.$i.'_id" name="userdata_'.$i.'_id"  value="'.$userdataid.'"  />';
								switch( $userfield->type ) {
									case 'text':
										echo '<input type="text" id="userfields_'.$i.'" name="userfields_'.$i.'" size="'.$userfield->size.'" value="'. $fvalue .'" '.$cssclass .$maxlength . $readonly . ' />';
										break;
									case 'emailaddress':
										echo '<input type="text" id="userfields_'.$i.'" name="userfields_'.$i.'" size="'.$userfield->size.'" value="'. $fvalue .'" '.$cssclass .$maxlength . $readonly . ' />';
										break;
									case 'date':
										$userfieldid = 'userfields_'.$i;	
										$userfieldid = "'".$userfieldid."'";
										if($jversion == '1.5') {
											echo '<input type="text" id="userfields_'.$i.'" name="userfields_'.$i.'" readonly size="'.$userfield->size.'" value="'. $fvalue .'" '.$cssclass .$maxlength . $readonly . ' />';
											echo '<input type="reset" class="button" value="..." onclick="return showCalendar('.$userfieldid.',\'%Y-%m-%d\');"  />';
										} else echo JHTML::_('calendar', $fvalue,'userfields_'.$i, 'userfields_'.$i,$js_dateformat,array('class'=>'inputbox', 'size'=>'10',  'maxlength'=>'19')); 
										break;
									case 'textarea':
										echo '<textarea name="userfields_'.$i.'" id="userfields_'.$i.'_field" cols="'.$userfield->cols.'" rows="'.$userfield->rows.'" '.$readonly.'>'.$fvalue.'</textarea>';
										break;	
									case 'checkbox':
										echo '<input type="checkbox" name="userfields_'.$i.'" id="userfields_'.$i.'_field" value="1" '.  'checked="checked"' .'/>';
										break;	
									case 'select':
										$htm = '<select name="userfields_'.$i.'" id="userfields_'.$i.'" >';
										if (isset ($ufield[2])){
											foreach($ufield[2] as $opt){
												if ($opt->id == $fvalue)
													$htm .= '<option value="'.$opt->id.'" selected="yes">'. $opt->fieldtitle .' </option>';
												else
													$htm .= '<option value="'.$opt->id.'">'. $opt->fieldtitle .' </option>';
											}
										}
										$htm .= '</select>';	
										echo $htm;
								}
								echo '</td></tr>';
							}
						}	 
					}	

			}
			
		} 
		echo '<input type="hidden" id="userfields_total" name="userfields_total"  value="'.$i.'"  />';
		?>
	<tr><td colspan="54" height="10"></td></tr>
	<tr>
		<td colspan="54" align="center">
		<input class="button" type="submit" name="submit_app" value="<?php echo JText::_('JS_SAVEJOB'); ?>" />
		</td>
	</tr>
    </table>
			<?php 
				if(isset($this->job)) {
					if (($this->job->created=='0000-00-00 00:00:00') || ($this->job->created==''))
						$curdate = date('Y-m-d H:i:s');
					else  
						$curdate = $this->job->created;
				}else
					$curdate = date('Y-m-d H:i:s');
				
			?>
			<input type="hidden" name="created" value="<?php echo $curdate; ?>" />
			<input type="hidden" name="view" value="jobposting" />
			<input type="hidden" name="layout" value="viewjob" />
			<input type="hidden" name="uid" value="<?php echo $this->uid; ?>" />
			<input type="hidden" name="option" value="<?php echo $this->option; ?>" />
			<input type="hidden" name="task" value="savejob" />
			<input type="hidden" name="check" value="" />
			<input type="hidden" name="packageid" value="<?php echo $this->packagedetail[0]; ?>" />
			<input type="hidden" name="paymenthistoryid" value="<?php echo $this->packagedetail[1]; ?>" />
			<input type="hidden" name="enforcestoppublishjob" value="<?php echo $this->packagedetail[2]; ?>" />
			<input type="hidden" name="enforcestoppublishjobvalue" value="<?php echo $this->packagedetail[3]; ?>" />
			<input type="hidden" name="enforcestoppublishjobtype" value="<?php echo $this->packagedetail[4]; ?>" />
			
		  <input type="hidden" name="Itemid" id="Itemid" value="<?php echo $this->Itemid; ?>" />
		  <input type="hidden" name="id" value="<?php if(isset($this->job)) echo $this->job->id; ?>" />
		  
		  
<script language=Javascript>
function dochange(src, val){
	var pagesrc = 'job_'+src;
	document.getElementById(pagesrc).innerHTML="Loading ...";
	var xhr; 
	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e) 
	{
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2) 
		{
		  try {  xhr = new XMLHttpRequest();     }
		  catch (e3) {  xhr = false;   }
		}
	 }

	xhr.onreadystatechange = function(){
      if(xhr.readyState == 4 && xhr.status == 200){
        	document.getElementById(pagesrc).innerHTML=xhr.responseText; //retuen value

			if(src=='state'){
				countyhtml = "<input class='inputbox' type='text' name='county' size='40' maxlength='100'  />";
				cityhtml = "<input class='inputbox' type='text' name='city' size='40' maxlength='100'  />";
				document.getElementById('job_county').innerHTML=countyhtml; //retuen value
				document.getElementById('job_city').innerHTML=cityhtml; //retuen value
			}else if(src=='county'){
				cityhtml = "<input class='inputbox' type='text' name='city' size='40' maxlength='100'  />";
				document.getElementById('job_city').innerHTML=cityhtml; //retuen value
			}
      }
    }
 
	xhr.open("GET","index.php?option=com_wrecruit&task=listaddressdata&data="+src+"&val="+val,true);
	xhr.send(null);
}

function getdepartments(src, val){
	document.getElementById(src).innerHTML="Loading ...";
	var xhr; 
	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e) {
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2) {
		  try {  xhr = new XMLHttpRequest();     }
		  catch (e3) {  xhr = false;   }
		}
	 }

	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200){
			document.getElementById(src).innerHTML=xhr.responseText; //retuen value
		}
	}
 
	xhr.open("GET","index.php?option=com_wrecruit&task=listdepartments&val="+val,true);
	xhr.send(null);
}
function fj_getsubcategories(src, val){
	var xhr;
	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e){
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2) {
		  try {  xhr = new XMLHttpRequest();     }
		  catch (e3) {  xhr = false;   }
		}
	 }

	xhr.onreadystatechange = function(){
            if(xhr.readyState == 4 && xhr.status == 200){
        	document.getElementById(src).innerHTML=xhr.responseText; //retuen value
            }
        }

	xhr.open("GET","index.php?option=com_wrecruit&task=listsubcategories&val="+val,true);
	xhr.send(null);
}

</script>
			  

</form>
<?php 
} else{ // can not add new job
	echo "<strong><font color='red'>".JText::_('JS_JOB_LIMIT_EXCEED')." <a href='index.php?option=com_wrecruit&view=employer&layout=packages&Itemid=$this->Itemid'>".JText::_('JS_EMPLOYER_PACKAGES')."</a></font></strong>";
}
} else{ // not allowed job posting
	echo JText::_('JS_YOU_ARE_NOT_ALLOWED_TO_VIEW');
}
}//ol
?>
<div width="100%">
<?php include_once('components/com_wrecruit/views/fr_jscr.php'); ?>
</div>
